<?php

    function msgexit($msg)
    {
        echo $msg;
        exit;
    }

    function msglogexit($msg, $log=LOGFN_GENERAL)
    {
        $r = mylog($msg, $log);
        echo $msg;
        exit;
    }

    function mylog($msg, $logfile=LOGFN_GENERAL)
    {
        $msg = '['.getmypid().'] ['.get_datetime().'] '.$msg."\n";
        $r = file_put_contents($logfile, $msg, FILE_APPEND);
        return $r;
    }

    function get_datetime( $tm=null )
    {
        if ( !$tm ) $tm = time();
        return date( "Y-m-d H:i:s", $tm );
    }
?>